home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
ISSUE03
/
TYPECAST
/
COLOURSU.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-07-08
|
1KB
|
65 lines
unit Coloursu;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
LowLbl: TLabel;
HighLbl: TLabel;
WholeLbl: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
LoWord, HiWord: Longint;
Tag: Longint;
begin
Color := RGB(Random(256), Random(256), Random(256));
Tag := Color;
LoWord := Tag and $FFFF;
HiWord := Tag shr 16;
HighLbl.Caption := '$' + IntToHex(HiWord, 4);
LowLbl.Caption := '$' + IntToHex(LoWord, 4);
WholeLbl.Caption := '$' + IntToHex(Tag, 8);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
LoWord, HiWord: Longint;
Tag: Longint;
begin
Color := RGB(Random(256), Random(256), Random(256));
Tag := Color;
LoWord := Word(Tag);
HiWord := LongRec(Tag).Hi;
HighLbl.Caption := '$' + IntToHex(HiWord, 4);
LowLbl.Caption := '$' + IntToHex(LoWord, 4);
WholeLbl.Caption := '$' + IntToHex(Tag, 8);
end;
initialization
Randomize;
end.